package com.gitee.kobe577590.generator;

import java.util.List;

import com.gitee.kobe577590.validator.exception.ValidateException;
import com.jfinal.template.Engine;
import com.jfinal.template.Template;

public class ExampleGeneratorImpl  extends AbstractGenerator{

	@Override
	public void config(List<GeneratorItem> items ) {
		
		this.engine = Engine.create("default").setBaseTemplatePath("/Users/tianpengtech/Documents/export/");
		GeneratorItem item = new GeneratorItem();
		item.setCodeTemplatePath("codeTemp.html");
		item.setOutPutPageName("CodeTemplate.java");
		item.setOutPutPath("/Users/tianpengtech/Documents/export/codeOut");
		items.add(item);
		
		
		GeneratorItem item1 = new GeneratorItem();
		item1.setCodeTemplatePath("codeTemp.html");
		item1.setOutPutPageName("CodeTemplate1.java");
		item1.setOutPutPath("/Users/tianpengtech/Documents/export/codeOut");
		items.add(item1);
		this.items = items;
		
	}

	public static void main(String[] args) {
		AbstractGenerator g = new ExampleGeneratorImpl();
		try {
			g.execute();
		} catch (ValidateException e) {
			e.printStackTrace();
		}
	}


	@Override
	public String parseTemplate(Template template) {
		this.params.put("name", "huchengsong");
		String data = template.renderToString(this.params);
		return data;
	}
}
